package com.demo.ssm.controller;

import com.demo.ssm.service.HelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author gatts, 2020/8/2 17:17
 */

@RestController
public class HelloController {

    @Autowired
    HelloService helloService;

    /**
     * consumes, request的content-type是json
     * produces, 浏览器调用html解析器处理，字符集utf-8
     */
    @GetMapping(value = "/", consumes = "application/json", produces = "text/html;charset=utf-8")
    public String hello(){
        return helloService.sayHello() + ", json格式请求";
    }

    @GetMapping(value = "/", produces = "text/html;charset=utf-8")
    public String hello1(){
        return helloService.sayHello() + ", 非json格式请求";
    }

}
